package ex2.pukepai;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/10 15:38
 * @DESCRIBE
 */
public class Game {
    public static void main(String[] args) {
        Map<String,Integer> mapPrize = new HashMap<>();
        mapPrize.put("同花顺", 100);
        mapPrize.put("四条", 80);
        mapPrize.put("满堂红", 60);
        mapPrize.put("同花", 40);
        mapPrize.put("顺子", 20);
        mapPrize.put("三条", 5);
        mapPrize.put("两对", -10);
        mapPrize.put("一对", -20);
        mapPrize.put("杂牌", -30);

        Poker poker = new Poker();
        int score = 100;
        Scanner sc = new Scanner(System.in);
        while (score > 0) {
            System.out.println("请下注：");
            int bet = sc.nextInt();
            sc.nextLine();//吃掉换行符
            //减去下注的钱并得到第一手牌
            score -= bet;
            System.out.println("current score:" + score);
            List<Card> hand = poker.getOneHand();
            System.out.println(hand);
            System.out.println(poker.getHandType(hand));
            System.out.println();
            System.out.println("请输入想换的牌【1-5】：（用空格分割，回车不换牌）");
            String info = sc.nextLine();
            //直接回车不换牌
            if (!info.equals("")){
                String[] arr = info.split(" ");
                for (int i = 0; i < arr.length; i++){
                    int no = Integer.parseInt(arr[i]);
                    no--;
                    Card card = poker.getOneCard(i+5);
                    hand.remove(no);
                    hand.add(no,card);
                }
            }
            System.out.println(hand);
            String type = poker.getHandType(hand);
            System.out.println(type);
            int prize = mapPrize.get(type);
            score += bet * prize;
            System.out.println("current score " + score);
        }
    }
}
